from tortoise import BaseDBAsyncClient

RUN_IN_TRANSACTION = True


async def upgrade(db: BaseDBAsyncClient) -> str:
    return """
        CREATE TABLE IF NOT EXISTS `class` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT COMMENT '班级ID',
    `name` VARCHAR(50) NOT NULL COMMENT '班级名称'
) CHARACTER SET utf8mb4 COMMENT='班级表';
CREATE TABLE IF NOT EXISTS `student` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL COMMENT '学生姓名',
    `username` VARCHAR(50) NOT NULL COMMENT '学生用户',
    `password` VARCHAR(50) NOT NULL COMMENT '密码',
    `stuNo` VARCHAR(50) NOT NULL COMMENT '学号',
    `clas_id` INT NOT NULL,
    CONSTRAINT `fk_student_class_82ffb504` FOREIGN KEY (`clas_id`) REFERENCES `class` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4 COMMENT='学生表';
CREATE TABLE IF NOT EXISTS `teacher` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL COMMENT '老师姓名',
    `username` VARCHAR(50) NOT NULL COMMENT '老师账户',
    `password` VARCHAR(50) NOT NULL COMMENT '密码'
) CHARACTER SET utf8mb4 COMMENT='教师表';
CREATE TABLE IF NOT EXISTS `course` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `name` VARCHAR(50) NOT NULL COMMENT '课程名称',
    `teacher_id` INT NOT NULL COMMENT '授课教师',
    CONSTRAINT `fk_course_teacher_2de38fe7` FOREIGN KEY (`teacher_id`) REFERENCES `teacher` (`id`) ON DELETE CASCADE
) CHARACTER SET utf8mb4 COMMENT='课程表';
CREATE TABLE IF NOT EXISTS `aerich` (
    `id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
    `version` VARCHAR(255) NOT NULL,
    `app` VARCHAR(100) NOT NULL,
    `content` JSON NOT NULL
) CHARACTER SET utf8mb4;
CREATE TABLE IF NOT EXISTS `student_course` (
    `student_id` INT NOT NULL,
    `course_id` INT NOT NULL,
    FOREIGN KEY (`student_id`) REFERENCES `student` (`id`) ON DELETE CASCADE,
    FOREIGN KEY (`course_id`) REFERENCES `course` (`id`) ON DELETE CASCADE,
    UNIQUE KEY `uidx_student_cou_student_0d222b` (`student_id`, `course_id`)
) CHARACTER SET utf8mb4;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
    return """
        """


MODELS_STATE = (
    "eJztmW1P2zAQgP8K6icmsSl9SRv2rXRDYwyQgE2TxhS5iZNGpHaxnUGF+t9nO0ntpElI1x"
    "XC1i99Od859uPznc95bE2xC0P6bhQC2nq/99hCYAr5j4z8YK8FZjMlFQIGxqFUdLhGrDKm"
    "jACHcaEHQgq5yIXUIcGMBRgJ1Zto0IUu/4RgcBNZVt8Sdi52uGGA/HKVCAV3EbQZ9iGbQM"
    "IVf/zk4gC58AHS9O/s1vYCGLqZeQSu6EDKbTafSdkJYsdSUTx9bDs4jKZIKc/mbILRUjtA"
    "TEh9iCABDIruGYnE9FAUhgmGdMbxSJVKPETNxoUeiEIBSVhXMzr5kOeT2DgYCdZ8ZPGi+e"
    "KJbzvt3qBndfs9i6vIUS0lg0U8VcUhNpQ0zq9bC9kOGIg1JFLFUH6vUBxNACnGmOrnQPIh"
    "50Gm2KpIpgKFUrlXfZY3kdkzxO9Dz6hJdQoe7BAin034X9OoQPhteDn6NLzcN403om/Mt0"
    "G8Oc6Tlo5sWiyEm3q3GmQhGAPn9h4Q1860KPyURS4Ug1pZgqPE8vj0EoZATnsVe7KTr+Je"
    "nnUFUuGTrBepC6XSZMNIYLiDy4itNk0707wEIODLUYtniyelsQ1HhMLCqBe3VMc9pVMj8F"
    "ljD3LnA8a4NPAVqfw/ga+2q+yCXVmw0x2oCcHuQPNGBoHDHdheyyuzRk9757YB97uWlWLu"
    "m+YhxwyNla28PbddyR4rfFfhHmMCAx+dwrlkfMIHBZBT5LFJ7LtWPb0WtmXZg4sJuF/Gxp"
    "w/8anz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